home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / source_code / dhtmlunl / dhtml.exe / CD Content / Chap08 / dun8_9.txt < prev   
Encoding:
Text File  |  1997-12-18  |  707 b   |  30 lines

  1. <script language="JavaScript">
  2. <!---//
  3. //returns "2" for a JavaScript 1.0 compliant browser
  4. //or "3" for a JavaScript 1.1 or higher browser
  5. function whichVersion() {
  6.    var myBrowser = navigator.userAgent;
  7.    if(myBrowser.lastIndexOf("MSIE") != -1) return "2";
  8.    if((myBrowser.lastIndexOf("4.0") != -1) ||
  9.      (myBrowser.lastIndexOf("3.0") != -1)) {
  10.      return "3";
  11.      } else {
  12.      return "2";
  13.    }
  14. }
  15.  
  16. function someFunction() {
  17.    //wrap this function in a conditional whichVersion()
  18.    if (whichVersion() == "3") {
  19.  
  20.    //JavaScript 1.1 specific code goes here....
  21.  
  22.    }
  23.  
  24.    //JavaScript 1.0 compatible code goes here....
  25.  
  26.  
  27. }
  28. //--->
  29. </script>
  30.